
<template>
          <el-input-number v-model="limitNum"
                        controls-position="right"
                        :style="{width: width+'%'}"
                        size="small"
                        :min="-1"
                        :placeholder="$t('model.alldata')"
                        ></el-input-number>
</template>

<script>
export default {
  props: {
    width: Number,
    qureyInfo: {
      type: Object,
      default: () => {}
    }

  },
  data () {
    return {
      limitNum: undefined
    }
  },
  watch: {
    limitNum (val) {
      // eslint-disable-next-line
      if (val == -1) {
        this.limitNum = undefined
      }
    },
    qureyInfo: {
      handler: function (val) {
        try {
          // eslint-disable-next-line
          if (val.rowLimit && val.rowLimit != -1) {
            this.limitNum = val.rowLimit
          }
        } catch (error) {
          this.limitNum = null
        }
      },
      deep: true
    }
  },
  created () {
    this.init()
  },
  methods: {
    init () {
      try {
        this.limitNum = Number(this.qureyInfo.rowLimit) ? this.qureyInfo.rowLimit : undefined
      } catch (err) { }
    },
    getLimitValue () {
      try {
        return this.limitNum ? this.limitNum : undefined
      } catch (error) {
        return ''
      }
    },
    clearLimit () {
      this.qureyInfo.rowLimit = undefined
      this.$forceUpdate()
    }
  }
}
</script>

<style scoped lang="scss">

</style>
